package com.apex.lottery.common.exception;

import com.apex.lottery.common.errorcode.ControllerErrorCodeConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.apex.lottery.common.errorcode.ErrorCode;

/**
 * @ClassName ControllerException
 * @Description Controller异常处理
 * @Author ZJX
 * @Date 2024/9/22 12:04
 * @Version 1.0
 */

@Data
@EqualsAndHashCode(callSuper = true) // 使用父类的 equals hashcode
public class ControllerException extends RuntimeException {

    /**
     * 异常码
     *  @see ControllerErrorCodeConstants
     */
    private Integer code;
    private String message;

    public ControllerException() {
    }

    public ControllerException(String message, Integer code) {
        this.message = message;
        this.code = code;
    }

    public ControllerException(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }
}
